package org.iku.crawl;

import java.util.List;
import java.util.Set;

import org.heydr.data.ResourceEngine;
import org.heydr.entity.Info;
import org.heydr.entity.Site;
import org.heydr.entity.Url;
import org.iku.crawl.dao.ResourceDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemResourceEngine extends ResourceEngine{

	@Autowired
	private ResourceDAO resourceDao;
	
	@Override
	public void storeUrls(List<Url> urls) {
		for(Url url : urls){
			resourceDao.storeUrl(url);
		}
	}

	@Override
	public List<Site> availableSites(){
		return resourceDao.availableSiteInfos();
	}
	
	@Override
	public List<Url> availableUrls(int size) {
		return resourceDao.availableUrls(size);
	}

	@Override
	public void finishedTasks(List<Url> urls) {
		for(Url url : urls){
			resourceDao.updateUrl(url);
		}
	}

	@Override
	public void storeInfo(Info info) {
		resourceDao.storeItemInfo(info);
	}

}
